﻿@model ZhongheCms.Models.GswTblShipLine
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
    int rid = 0;
    if (Model.ShioRouteLine != null)
    {
        rid = Model.ShioRouteLine.Id;
    }
    if (string.IsNullOrEmpty(Model.OriginPlace))
    {
        Model.OriginPlace = "常熟";
    }
}
@section css{

    <link rel="stylesheet" href="/Assets/webuploader/webuploader.css" />

}
<div class="row">
    <div class="col-xs-12 col-sm-12 widget-container-col">
        @using (Html.BeginForm("Create", "ShipLine", new { id = Model.Id, rid, ViewBag.m, ViewBag.f, ViewBag.p, ViewBag.fid, ViewBag.keywords }, FormMethod.Post,
            new { name = "myForm", id = "myForm", @class = "form-horizontal", role = "form" }))
        {
            <div class="widget-box">
                <div class="widget-header">
                    <h5 class="widget-title">@ViewBag.f</h5>

                    <div class="widget-toolbar">
                    </div>
                </div>

                <div class="widget-body">


                    <div class="widget-main">

                        <div class="form-group">
                            <table id="sample-table-1" class="table table-bordered ">
                                <tbody>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">线路序号
                                        </td>
                                        <td>

                                            <input type="text" id="Lno" name="Lno" placeholder="" class="col-xs-10 col-sm-5"  data-val="true"  data-val-number="线路序号为非法的数字格式" data-val-regex="线路序号为非法的数字格式"
                                                   data-val-regex-pattern="^(-?\d+)(\.\d+)?$" data-val-required="线路序号为非法的数字格式" value="@Model.Lno" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="Lno" data-valmsg-replace="true"></span>

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">始发地
                                        </td>
                                        <td>
                                            <input  id="OriginPlace" name="OriginPlace" placeholder="" type="text" class="form-control" value="@Model.OriginPlace" data-val="true" data-val-required="始发地不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="OriginPlace" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">目的地
                                        </td>
                                        <td>

                                            <input  id="EndPlace" name="EndPlace" placeholder="" type="text" class="form-control" value="@Model.EndPlace" data-val="true" data-val-required="目的地不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="EndPlace" data-valmsg-replace="true"></span>

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">总里程
                                        </td>
                                        <td>
                                            <input  id="TotalDistance" name="TotalDistance" placeholder="" type="text" class="form-control" value="@Model.TotalDistance" data-val="true" data-val-required="总里程不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="TotalDistance" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">负责人
                                        </td>
                                        <td>

                                            <input  id="Manager" name="Manager" placeholder="" type="text" class="form-control" value="@Model.Manager" />


                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">营业电话
                                        </td>
                                        <td>
                                            <input  id="Tel" name="Tel" placeholder="" type="text" class="form-control" value="@Model.Tel"  />
                                            <span class="field-validation-valid help-block" data-valmsg-for="Tel" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>
                                    <tr style="vertical-align: top">
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">线路图
                                        </td>
                                        <td>
                                            <img width="200" height="100" alt="200x100" id="img" src="@Model.LinePic" />


                                            <div class="btns" style="margin-top: 5px">
                                                <div id="picker">
                                                    点击选择图片
                                                </div>

                                            </div>
                                            <input type="hidden" id="LinePic" name="LinePic" value="@Model.LinePic" />
                                        </td>
                                        <td colspan="2">
                                            <table id="sample-table-2" class="table table-bordered ">
                                                <tr>
                                                    <td class="align-right" style="background: #f6f6f6; text-align: center">沿线城市
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td>

                                                       城市名: <input type="text" id="RouteLine" name="RouteLine" placeholder="城市名称" class="form-control"  value="@Model.ShioRouteLine.RouteLine" />


                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td>

                                                     里程数:  <input type="text" id="Distance" name="Distance" placeholder="里程数" class="form-control"  value="@Model.ShioRouteLine.Distance" />


                                                    </td>

                                                </tr>
                                            </table>
                                        </td>

                                    </tr>

                                </tbody>
                            </table>
                        </div>


                        @if (ViewBag.scode == "1")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-ok"></i>
                                    提示信息
                                </strong>

                                信息保存成功!
																
                            </div>
                        }
                        @if (ViewBag.scode == "0")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-danger">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-remove"></i>
                                    错误提示
                                </strong>

                                @Html.ValidationSummary(true)

                            </div>

                        }
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-check bigger-110"></i>
                                    保存&nbsp;&nbsp;
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="button" onclick="funBack()">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-undo bigger-110"></i>
                                    返回&nbsp;&nbsp;
                                </button>
                            </div>
                        </div>
                        @if (Model.ShioRouteLines.Count > 0)
                        {
                                             
                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                       
                                        <th class="center">修改
                                        </th>
                                        <th>沿线城市
                                        </th>

                                        <th>里程数
                                        </th>
                                        <th class="center">删除
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var item in Model.ShioRouteLines)
                                    {
                                                            
                                                           
                                        <tr>
                                            <td class="center">
                                                <a href="/ShipLine/Create/@Model.Id?rid=@item.Id&m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&keywords=@ViewBag.keywords"><span class="btn btn-xs btn-info no-border">
                                                    <i class="fa fa-pencil-square-o"></i></span></a>
                                            </td>
                                            <td>
                                                @item.RouteLine

                                            </td>
                                            <td>
                                                @item.Distance
                                            </td>
                                            <td class="center">
                                                <a  class="confirm" href="/ShipLine/RouteDelete/@Model.Id?rid=@item.Id&m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&keywords=@ViewBag.keywords"><span
                                                    class="btn btn-xs btn-danger no-border"><i class="fa fa-trash-o"></i></span></a>
                                            </td>

                                        </tr>
                                       
                                    }
                                </tbody>
                            </table>

                                         
                        }



                    </div>



                </div>

            </div>
        }

    </div>


</div>
@section js{
    <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.bootstrap.js"></script>
    <script src="/Assets/webuploader/webuploader.js" type="text/javascript"></script>
    <script type="text/javascript">

        jQuery(function ($) {



            var uploader = WebUploader.create({

                resize: true,

                // 自动上传。
                auto: true,

                // swf文件路径
                swf: '/Assets/webuploader/Uploader.swf',

                // 文件接收服务端。
                server: '/GsnService/UploadFileToQiniu/',

                // 选择文件的按钮。可选。
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: '#picker'
            });

            // 当有文件添加进来的时候
            //uploader.on('fileQueued', function (file) {
            //    $list.append('<div id="' + file.id + '" class="item">' +
            //    '<h4 class="info">' + file.name + '</h4>' +
            //    '<p class="state">等待上传...</p>' +
            //    '</div>');
            //});

            // 文件上传过程中创建进度条实时显示。
            uploader.on('uploadProgress', function (file, percentage) {
                var $li = $('#' + file.id),
            $percent = $li.find('.progress .progress-bar');
                // 避免重复创建
                if (!$percent.length) {
                    $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo($li).find('.progress-bar');
                }
                $li.find('p.state').text('上传中');

                $percent.css('width', percentage * 100 + '%');
            });
            uploader.on('uploadSuccess', function (file) {
                $('#' + file.id).find('p.state').text('已上传');
            });
            uploader.on('uploadError', function (file) {
                $('#' + file.id).find('p.state').text('上传出错');
            });
            // 完成上传完了，成功或者失败，先删除进度条。
            uploader.on('uploadComplete', function (file) {
                $('#' + file.id).find('.progress').fadeOut();
                //alert(file.name);
            });

            //获取返回值
            uploader.on('uploadAccept', function (file, response) {
                //response.FileName
                //  $('#fName').val(response.FileName);
                $('#LinePic').val(response.SavePath + response.SaveName);
                $('#img').attr("src", response.SavePath + response.SaveName);
            });

        });
        function funBack() {
            document.location = "/ShipLine/Index/0?m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&keywords=@ViewBag.keywords";
        }
    </script>
}
